package com.welsy.classroom.command
{
	import com.adobe.cairngorm.commands.Command;
	import com.adobe.cairngorm.control.CairngormEvent;
	import flash.events.Event;
	import mx.controls.Alert;
	import mx.collections.ArrayCollection;
	import mx.rpc.IResponder;
	import com.welsy.classroom.event.SaveItersEvent;
	import com.welsy.classroom.business.SaveItersDelegate;
	import mx.rpc.events.ResultEvent;
	
	public class SaveItersCommand implements Command, IResponder
	{
		
		public function execute(event : CairngormEvent):void {
			var delegate : SaveItersDelegate = new SaveItersDelegate(this);
			var saveItersEvent : SaveItersEvent = SaveItersEvent(event);
			delegate.saveItinera(saveItersEvent.classId, saveItersEvent.iters);
		}
		
		public function result( event : Object) : void {
			/*var resultlist:XMLList = XMLList(event.result)
			var result:String = XML(resultlist.child(0).child(0)).toString()
			if(result.toLowerCase() == "ok") {
				UserMgtModelLocator.getInstance().classEditingSucceeded = true;
				CourseModelLocator.getInstance().classEditingSucceeded = true;
			} else {
				UserMgtModelLocator.getInstance().classEditingSucceeded = false;
				CourseModelLocator.getInstance().classEditingSucceeded = false;
				trace(result);
			}*/
		}
		
		public function fault( event : Object ) : void {
			//UserMgtModelLocator.getInstance().classEditingSucceeded = false;
			//report the error
			Alert.show("classroom.command.SaveItersCommand.fault!");
		}
	}
}